﻿using Order.Domain.Entity;
using Order.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;


namespace Order.EntityFrameworkCore.RepositoryImpl
{
    public class OrderRepository : IOrderRepository
    {
        private readonly OrderContext _orderContext;

        public OrderRepository(OrderContext orderContext)
        {
            this._orderContext = orderContext;
        }

        public async Task AddOrder(Domain.Entity.Order order)
        {
           await _orderContext.AddAsync(order);
        }

        public async Task<Domain.Entity.Order> GetOrder(string orderNo)
        {
           return await _orderContext.OrderInfo.FirstOrDefaultAsync(e => e.OrderUniqueCode == orderNo);
        }
     
    }
}
